using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using AntDesign;
using AntDesign.Charts;
using AntDesign.ProLayout;
using System.Net.Http;
using System.Net.Http.Json;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Routing;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Http;
using Microsoft.JSInterop;
using ZFY.UMC.BlazorWebAssembly;
using Microsoft.AspNetCore.Authorization;
using ZFY.UMC.BlazorWebAssembly.Shared;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;

using ZFY.Core;

namespace ZFY.UMC.BlazorWebAssembly.Pages.Auth
{
    public partial class Authentication
    {
        [Parameter]
        public string Action { get; set; }
        //[CascadingParameter]
        //private Task<AuthenticationState> AuthenticationStateTask { get; set; }
        [Inject]
        public CurrentUserProfile CurrentUserProfile { get; set; }
        [Inject]
        public NavigationManager NavigationManager { get; set; }
        void SetUserAsync(RemoteAuthenticationState remoteAuthenticationState)
        {
            //var res = await AuthenticationStateTask;

            //CurrentUserProfile.PhoneNumber = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.PhoneNumber)?.Value;
            //CurrentUserProfile.UserName = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.Name)?.Value;
            //CurrentUserProfile.Avatar = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.Avatar)?.Value;
            //CurrentUserProfile.Email = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.Email)?.Value;
            //CurrentUserProfile.NickName = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.NickName)?.Value;
            //CurrentUserProfile.UserId = res.User.Claims.FirstOrDefault(x => x.Type == ZFYProfileClaimTypes.UserId)?.Value;

            Console.WriteLine(CurrentUserProfile.PhoneNumber);

        }

        void HanldLogOutSuccess(RemoteAuthenticationState remoteAuthenticationState)
        {

            Console.WriteLine("loggout");
            CurrentUserProfile = new CurrentUserProfile();

            NavigationManager.NavigateTo("");
        }
    }
}